<?php

$client = stream_socket_client(
    'tcp://127.0.0.1:8000',
    $errno,
    $errStr,
    1,
    STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT
);

fwrite($client,"GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");

\Swoole\Event::add($client, function($fp) {
    $resp = fread($fp, 8192);

    var_dump($resp . PHP_EOL);

    //socket处理完成后，从epoll事件中移除socket
    swoole_event_del($fp);

    fclose($fp);
});

echo "Finish\n";  //Swoole\Event::add 不会阻塞进程，这行代码会顺序执行